package com.lancoo.znbkxx.teacher.adapter

import android.graphics.Color
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.model.data.AnswerSkillData
import kotlinx.android.synthetic.main.item_answer_skill_card.view.*
import java.util.ArrayList

/**
 * Created by wealive on 2021/3/12.
 *
 *
 */
class SelectAnswerSkillAdapter(
        val listener: View.OnClickListener, data: ArrayList<AnswerSkillData>?) :
        BaseQuickAdapter<AnswerSkillData, BaseViewHolder>(data) {

    init {
        mLayoutResId = R.layout.item_answer_skill_card
    }

    override fun convert(helper: BaseViewHolder, item: AnswerSkillData?) {
        with(helper.itemView) {
            tv_title.text = item?.Title
            tv_text.text = item?.MainContext
            tv_add.setOnClickListener(listener)
            if (item!!.isSelect) {
                tv_add.apply {
                    text = "取消"
                    setTextColor(Color.parseColor("#00afff"))
                    setBackgroundResource(R.drawable.aibk_bg_cancel)
                }
            } else {
                tv_add.apply {
                    text = "添加"
                    setTextColor(Color.parseColor("#ffffff"))
                    setBackgroundResource(R.drawable.aibk_bg_add)
                }
            }
        }
    }
}